package com.yb.domain.goods;

import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.yb.base.annotation.Column;
import com.yb.base.annotation.Table;
import com.yb.base.entity.BaseEntity;
import com.yb.util.comm.DateTimeUtil;

@Table("shopmessager")
public class ShoperMessage extends BaseEntity {

	private String category;
	private String title;
	private Date creatime;
	private int shoperId;
	private String autding;
	private String descrt;
	private String recommend;
	private String isTop;
	private String deleteFlag;
	private String content;

	@Column(name = "reject")
	private String titleSpe;
	
	@Column(name = "reject")
	private String creatTimeFormat;
	@Column(name = "reject")
	private String creatTimeStr;

	public String getRecommend() {
		return recommend;
	}

	public void setRecommend(String recommend) {
		this.recommend = recommend;
	}

	public String getCreatTimeStr() {
		return creatTimeStr;
	}

	public void setCreatTimeStr(String creatTimeStr) {
		this.creatTimeStr = creatTimeStr;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getCreatime() {
		return creatime;
	}

	public void setCreatime(Date creatime) {
		this.creatime = creatime;
	}

	public int getShoperId() {
		return shoperId;
	}

	public void setShoperId(int shoperId) {
		this.shoperId = shoperId;
	}

	public String getAutding() {
		return autding;
	}

	public void setAutding(String autding) {
		this.autding = autding;
	}

	public String getDescrt() {
		return descrt;
	}

	public void setDescrt(String descrt) {
		this.descrt = descrt;
	}

	public String getTitleSpe() {
		if (null != title) {
			titleSpe = "<b>"+title+"</b>";
			String messageContent = getShortDesc();
			int length = title.length();
			String imgStr = "";
			if (null != content) {
				if (content.indexOf("img") != -1)
					imgStr += "<img src='../resource/img/image_s.gif'/>";
			}
//			System.out.println(titleSpe);
			if((length + messageContent.length())>56){
				titleSpe += imgStr+" "+messageContent.substring(0,56-length)+"...";
			}
		}
		if (null != category)
			if (category.length() > 4) {
				titleSpe = "【" + category.substring(0,1)+"..."+ category.substring(category.length()-2,category.length()) + "】   " + titleSpe;
			} else {
				titleSpe = "【" + category + "】   " + titleSpe;
			}
		else
			titleSpe = "【品牌介绍】 " + titleSpe;
		return titleSpe;
	}

	public void setTitleSpe(String titleSpe) {
		this.titleSpe = titleSpe;
	}

	public String getCreatTimeFormat() {
		if (null != creatime) {
			creatTimeFormat = DateTimeUtil.getDateToString(creatime,
					"yyyy-MM-dd kk:mm:ss");
		}
		return creatTimeFormat;
	}

	public void setCreatTimeFormat(String creatTimeFormat) {
		this.creatTimeFormat = creatTimeFormat;
	}

	public String getIsTop() {
		return isTop;
	}

	public void setIsTop(String isTop) {
		this.isTop = isTop;
	}

	public String getDeleteFlag() {
		return deleteFlag;
	}

	public void setDeleteFlag(String deleteFlag) {
		this.deleteFlag = deleteFlag;
	}

	public String getShortDesc() {
		if(null == content)
			return "";
		String temp = "";
		Pattern patt = Pattern.compile(">[*[^<]]+<");
		Matcher m = patt.matcher(content);
		while (m.find()) {
			String contentDesc = "";
			contentDesc = m.group(0);
			contentDesc = contentDesc.substring(1, contentDesc.length() - 1);
			contentDesc = contentDesc.replaceAll("\\r", "").replaceAll("\\n",
					"").replaceAll("\\t", "").replaceAll(" ", "").replaceAll(
					"&nbsp;", "");
			temp += contentDesc;
			if (temp.length() >= 100) {
				temp = temp.substring(0, 100) + "……";
				break;
			}
		}
		return temp;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

}
